package com.newzqxq.koalamoney.ui.activity;

import android.content.Intent;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.newzqxq.koalamoney.R;
import com.newzqxq.koalamoney.common.BaseActivity;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 总资产额/累计收益
 */

public class AssetsIncomeActivity extends BaseActivity {

    @BindView(R.id.title_assets_income)
    TextView title_assets_income;//总资产额/累计收益
    @BindView(R.id.title_mid_tv)
    TextView title_mid_tv;//标题

    @BindView(R.id.ai_accumulated_income)
    LinearLayout ai_accumulated_income; //累计收益UI
    @BindView(R.id.ai_total_assets)
    LinearLayout ai_total_assets; //总资产额UI

    @BindView(R.id.ai_outside_pink)
    TextView ai_outside_pink; //金额>0 外圈show

    private boolean showIt;  //切换 资产/收益

    private TranslateAnimation mShowAction, mHiddenAction;


    @Override
    protected int getContentViewId() {
        return R.layout.ui_assets_income;
    }

    @Override
    protected void initData() {
        setStartAnimation();
    }

    /**
     * 1：总资产额   2：累计收益
     */
    @Override
    protected void onResume() {
        super.onResume();
        Intent intent = getIntent();
        int showItem = intent.getIntExtra("showItem", 0);
        switch (showItem) {
            case 1:
                setTotalAssets();
                break;
            case 2:
                setAccumulatedEarnings();
                break;
        }
    }


    /**
     * 总资产额
     */
    private void setTotalAssets() {
        showIt = true;
        title_mid_tv.setText(R.string.my_total_assets);//title
        title_assets_income.setText(R.string.my_accumulated_earnings); //副标题  累计收益
        ai_total_assets.startAnimation(mShowAction);
        ai_total_assets.setVisibility(View.VISIBLE);//显示资产UI
        ai_accumulated_income.startAnimation(mHiddenAction);
        ai_accumulated_income.setVisibility(View.GONE); //显示累计UI
    }

    /**
     * 累计收益
     */
    private void setAccumulatedEarnings() {
        showIt = false;
        title_mid_tv.setText(R.string.my_accumulated_earnings);//title  累计收益
        title_assets_income.setText(R.string.my_total_assets);//副标题   总资产额
        ai_accumulated_income.startAnimation(mShowAction);
        ai_accumulated_income.setVisibility(View.VISIBLE); //显示累计UI
        ai_total_assets.startAnimation(mHiddenAction);
        ai_total_assets.setVisibility(View.GONE);//显示资产UI
    }

    /**
     * OnClicks
     *
     * @param view
     */
    @OnClick({R.id.title_relative_back,
            R.id.title_assets_income,
            R.id.ai_experience_gold_profit,
            R.id.ai_regular_financial_gain,
            R.id.ai_experience_gold,
            R.id.ai_capital,
            R.id.ai_interest})
    void AssetsIncomeOnClicks(View view) {
        switch (view.getId()) {
            case R.id.title_relative_back:
                //返回键
                finish();
                break;
            case R.id.title_assets_income:
                //副标题 操作
                if (showIt) {
                    setAccumulatedEarnings();
                } else {
                    setTotalAssets();
                }
                break;
            case R.id.ai_experience_gold_profit:
                //累计收益- 体验金收益
                break;
            case R.id.ai_regular_financial_gain:
                //累计收益- 定期理财收益
                break;
            case R.id.ai_experience_gold:
                //总资产额- 体验金
                break;
            case R.id.ai_capital:
                //总资产额- 待收本金
                break;
            case R.id.ai_interest:
                //总资产额- 待收利息
                break;
        }
    }

    //设置 显示/隐藏 动效
    private void setStartAnimation() {
        //显示动效
        mShowAction = new TranslateAnimation(
                Animation.RELATIVE_TO_SELF, 1.0f,
                Animation.RELATIVE_TO_SELF, 0.0f,
                Animation.RELATIVE_TO_SELF, 0.0f,
                Animation.RELATIVE_TO_SELF, 0.0f);
        mShowAction.setDuration(1000);

        //隐藏动效
        mHiddenAction = new TranslateAnimation(
                Animation.RELATIVE_TO_SELF, 0.0f,
                Animation.RELATIVE_TO_SELF, 1.0f,
                Animation.RELATIVE_TO_SELF, 0.0f,
                Animation.RELATIVE_TO_SELF, 0.0f);
        mHiddenAction.setDuration(1000);
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void clearMemory() {

    }
}
